import sys

if __name__ == "__main__":
    arg = sys.argv[1:]
    trainfile = arg[0]
    vectorfile = arg[1]
    classx = int(arg[2])
    docsinclass = []
    docsnotincls = []
    f = open(trainfile, 'r')
    for line in f:
        t = line.replace('\n','').split(' ')
        if int(t[1]) == classx:
            docsinclass.append(int(t[0]))
        else:
            docsnotincls.append(int(t[0]))
    f.close()
    f = open(vectorfile, 'r')
    fout = open('class%d.txt'%classx, 'w')
    for line in f:
        t = line.split(' ')
        if int(t[0]) in docsinclass:
            t[0] = '+1'
        elif not docsinclass:
            t[0] = '0'
        elif int(t[0]) in docsnotincls:
            t[0] = '-1'
        else:
            continue
        fout.write(' '.join(t))
    f.close()
    fout.close()
        